﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Validation;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Models
{
    public class PriceBussiness: IDbServices<bool, int, TblPrice>
    {
        BookingDB db = new BookingDB();


        public bool AddData(TblPrice e)
        {
            
            try
            {
                db.TblPrices.Add(e);
                db.SaveChanges();
                return true;
                //ok tuong tu o duoi lam di
            }
            catch (DbEntityValidationException ex){
                Console.Write(ex.Message);
            
            }
            throw new NotImplementedException();
        }

        public bool UpdateData(TblPrice e)
        {//doi xiu lam giao dien di de do tui lam phan do cho
            throw new NotImplementedException();
        }

        public bool DeleteData(int k)
        {
            throw new NotImplementedException();
        }

        public TblPrice GetDataByKey(int k)
        {
            throw new NotImplementedException();
        }

        public List<TblPrice> GetAll()
        {
            throw new NotImplementedException();
        }
    }
}
/*
        public bool AddData(TblPrice e)
        {
            try
            {
                db.TblPrices.Add(e);
                return true;
            }
            catch ( DbEntityValidationException ex)
            {
                Console.Write(ex.Message);
                return false;
            }
        }

        public bool UpdateData(TblPrice e)
        {
            try
            {
               
                db.Entry(e).State = EntityState.Modified;
                db.SaveChanges();
                return true;
            }
            catch (ValidationException ex)
            {

                return false;
            }
        }

        public bool DeleteData(int k)
        {
            TblPrice objPrice = new TblPrice();
            objPrice = db.TblPrices.Find(k);
            try
            {
                db.TblPrices.Remove(objPrice);
                db.SaveChanges();
                return true;

            }
            catch (DbUpdateConcurrencyException)
            {

                return false;
            }
        }

        public TblPrice GetDataByKey(int k)
        {
            try
            {
                return db.TblPrices.Find(k);
            }
            catch (Exception)
            {

                return null;
            }
        }

        public List<TblPrice> GetAll()
        {
            try
            {
                return db.TblPrices.ToList<TblPrice>();
            }
            catch (Exception)
            {

                return null;
            }
        }

      //  public string ex { get; set; }
 
 */